<template>
  <div>
    <div id="container">
      <div id="output">
        <div class="containerT flcc">
          <div class="fs30 c13">
            <div class="fs60">SANO</div>
            <div class="fs20">订单排产管理系统</div>
          </div>
          <form class="form" id="entry_form">
            <input class="tac" type="text" placeholder="用户名" id="entry_name" v-model="form.username">
            <input class="tac" type="password" placeholder="密码" id="entry_password" v-model="form.password">
            <button type="button" id="entry_btn" @click="submit()">登录</button>
            <div id="prompt" class="prompt"></div>
          </form>
        </div>
      </div>
    </div>
  </div>
</template>

<script>

import api from '@/assets/js/api'
import App from '@/App'
// import "@/assets/login/css/style.css"
// import $ from 'jquery'
import { Victor } from '@/assets/login/js/vector.js'
export default {
  name: 'login',
  comments: {App},
  data () {
    return {
      form: {
        username: '',
        password: ''
      }
    }
  },
  methods: {
    submit () {
      let _this = this
      api.post('/admin/api/login', _this.form, function (res) {
        console.log(res)
        if (res.s === 1) {
          setTimeout(function () {
            _this.$router.push('/admin/welcome')
          }, 500)
        } else {
          _this.$toast.error(res.i)
          // _this.$router.push('/admin/welcome')
        }
      })
      console.log(this.form)
    },
    clear () {
    }
  },
  created () {
    this.$progress.start()
    api.get('/admin/api/init', {}, function (res) {
    })
    let _this = this
    document.onkeydown = function (e) {
      var theEvent = window.event || e;
      var code = theEvent.keyCode || theEvent.which;
      if (code === 13) {
        _this.submit()
      }
    }
  },
  mounted () {
    this.$progress.done()
    Victor('container','output')
  }
}

</script>

<style>
  @import "../assets/login/css/style.css";
</style>
